<include file='Common:header' />

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

    <!-- #section:basics/sidebar -->

    <include file='Common:left' />
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div>
                            <div class="col-xs-12 col-sm-2">
                                <a href="__URL__/notice_listadd">
                                    <button class="btn btn-xs btn-info">添加公告</button>
                                </a>
                            </div>
                            <form id="leftnav" name="leftnav" method="post" action="" >
                                <input type="hidden" name="checkk" id="checkk" value="1" /><!--用于判断操作类型-->
                                <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th width="5%" class="center">
                                                <label class="pos-rel">
                                                    <input type="checkbox" class="ace"  id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
                                                    <span class="lbl"></span>							
                                                </label>						
                                            </th>
                                            <th width="15%">标题</th>
                                            <th width="37%">内容</th>
                                            <th width="13%">开启状态</th>
                                            <th width="13%">排序</th>
                                            <th width="22%" style="border-right:#CCC solid 1px;">操作</th>
                                        </tr>
                                    </thead>

                                    <tbody>

                                    <foreach name="news" item="v">
                                        <tr>
                                            <td class="center">
                                                <label class="pos-rel">
                                                    <input name='left_id[]' id="navid" class="ace"  type='checkbox' value='{$v.id}'>
                                                    <span class="lbl"></span>
                                                </label>
                                            </td>
                                            <td>{$v.notice_title}</td>

                                            <td>{$v.notice_content}</td>
                                            <td><if condition="$v['display'] eq 1">开启<else/><span class="red">禁用</span></if></td>
                                        <td><input name="{$v.id}" value=" {$v.sort}" class="list_order"/></td>
                                        <td>
                                            <div class="hidden-sm hidden-xs action-buttons">
                                                <a class="green" href="{:U('notice_listedit',array('id'=>$v['id']))}" title="修改">
                                                    <i class="ace-icon fa fa-pencil bigger-130"></i>																</a>
                                                <a class="red" href="javascript:;" onclick="return del({$v.id});" title="删除">
                                                    <i class="ace-icon fa fa-trash-o bigger-130"></i>																</a>															</div>														</td>
                                        </tr>
                                    </foreach>   
                                    <tr>
                                       <!--  <td align="left"><button id="btnsubmit" class="btn btn-white btn-yellow btn-sm">删</button> </td> -->
                                       <td><button  id="btnorder" class="btn btn-white btn-yellow btn-sm">排序</button></td>
                                        <td colspan="6" align="right">{$page}</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>

                <include file='Common:header_nav' />

            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->


    <script>
        $(function () {
            $("#btnsubmit").click(function () {
                $('#checkk').attr('value', 1);
                $('#leftnav').attr("action", "{:U('leftnavalldel')}");
            });

            $("#btnorder").click(function () {
                $('#checkk').attr('value', 0);
                $('#leftnav').attr("action", "{:U('noticeorder')}");
            });
        });


        function del(id) {
            layer.confirm('你确定要删除吗？', {icon: 3}, function (index) {
                layer.close(index);
                window.location.href = "__URL__/notice_del/id/" + id + "";
            });
        }

        function look(title, url, order, opentype) {
            layer.open({
                type: 1,
                title: '查看信息',
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                content: "<div class=look><ul><li>导航标题：" + title + "</li><li>U方法操作：" + url + "</li><li>列表排序：" + order + "</li></ul></div>"
            });
        }
    </script>
    <script>
        function unselectall() {
            if (document.myform.chkAll.checked) {
                document.myform.chkAll.checked = document.myform.chkAll.checked & 0;
            }
        }
        function CheckAll(form) {
            for (var i = 0; i < form.elements.length; i++) {
                var e = form.elements[i];
                if (e.Name != 'chkAll' && e.disabled == false)
                    e.checked = form.chkAll.checked;
            }
        }

    </script>
    <script>
        $(function () {
            $('#leftnav').ajaxForm({
                beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
                success: complete, // 这是提交后的方法
                dataType: 'json'
            });

            function checkForm() {
                if ($('#checkk').val() == 1) {
                    if ('' == $.trim($('#adminnav_title').val())) {
                        var chk_value = [];
                        $('input[id="navid"]:checked').each(function () {
                            chk_value.push($(this).val());
                        });

                        if (!chk_value.length) {
                            layer.alert('至少选择一个删除项', {icon: 6});
                            return false;
                        }
                    }
                }
            }

            function complete(data) {
                if (data.status == 1) {
                    layer.alert(data.info, {icon: 6}, function (index) {
                        layer.close(index);
                        window.location.href = data.url;
                    });
                } else {
                    layer.alert(data.info, {icon: 6}, function (index) {
                        layer.close(index);
                        window.location.href = data.url;
                    });
                }
            }

        });
    </script>
    <include file='Common:footer' />

</div><!-- /.main-container -->
</body>
</html>
